# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/5/27 17:21
from PyQt5.Qt import *


class Window(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('QListView布局网格学习')
		self.resize(500, 500)
		self.data_list = [f"Item{i}" for i in range(15)]
		self.setup_ui()

	def setup_ui(self):
		layout = QGridLayout(self)
		self.setLayout(layout)
		list_view = QListView()
		list_view.resize(200,200)
		slm = QStringListModel()
		slm.setStringList(self.data_list)
		list_view.setModel(slm)
		list_view.setWrapping(True)
		layout.addWidget(list_view)

		# 布局网格
		list_view.setGridSize(QSize(100,100))

		# 大小调整模式
		# list_view.setResizeMode(QListView.Fixed)
		# list_view.setResizeMode(QListView.Adjust)

		# list_view.setMovement(QListView.Static)
		# list_view.setMovement(QListView.Free)
		list_view.setMovement(QListView.Snap)
		QHeaderView


if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	window.show()
	sys.exit(app.exec_())